<template>
  <!-- 收藏 -->
  <div class="principal">
     <header>
      <div class="return" @click="returns">
        <i class="iconfont icon-zuojiantou"></i>
      </div>
      <div class="title">收藏</div>
    </header>
 <main>
      <!-- 选项栏 -->
    <van-tabs
      line-width="50%"
      class="tabs"
      style="height: 60px"
      v-model="active"
    >
      <div class="tabtext">
        <van-tab title="房源收藏" style="font-size: 16px; text-align: center">
          <main>
            <div class="contents" v-for="(item,index) in list" :key="index">
              <div>
                <img :src="item.carouselMap" alt="" />
              </div>
             <div class="contents1">
               
                <ul>
                  <li>{{item.areaName}}</li>
                  <li>{{item.roomTypeName}}-{{item.size}} ㎡</li>
                  <li>{{item.title}}</li>
                </ul>
                <div class="contents1_1">
                  <div>整租</div>
                  <span>{{item.priceNum}}元/月</span>
                </div>
              </div>
            </div>
         
          </main>
        </van-tab>
        <van-tab
          title="商品收藏"
          style="font-size: 16px; text-align: center"
        >
        <main>
            <div class="contents" v-for="(item,index) in shopList" :key="index">
              <div>
                <img :src="item.showImg" alt="" />
              </div>
             <div class="contents1">
               
                <ul>
                  <li>{{item.name}}</li>
                  <li>{{item.describe}}</li>
                  <!-- <li>{{item.title}}</li> -->
                </ul>
                <div class="contents1_1">
                  <div>好物</div>
                  <span>{{item.price}}元</span>
                </div>
              </div>
            </div>
        </main>
        </van-tab>
      </div>
    </van-tabs>
 </main>
  </div>
</template>

<script>
import {getCollection} from "../../api/index"
import {getShopCollection} from '../../api/index'
export default {
   data() {
    return {
    active: "",
    list:{
    },
    shopList:{

    }
        // {
        //     imgSrc: '',
        //     region:"北京香格里拉",
        //     type:"1室1厅",
        //     advantage:"距离地铁站1米",
        //     rent:"整租",
        //     money:"2000元/月",
        // }     
    };
  },
  mounted(){
    this.collection(),
    this.shopCollection()
  },
   methods:{
  //跳转
     returns(){
         this.$router.push('/my')
     },
     async collection(){    
       
        let obj = {
          userID :  window.localStorage.user_id
        }
        let {
          data,
          meta: { msg, status }
        } = await getCollection(obj);
        // console.log(data);
        this.list = data
        this.list.forEach( (item, index)=> {
          item.carouselMap = 'http://127.0.0.1:3000/newImg/' +item.carouselMap.split('|')[0]
          item.areaName = item.areaName.split('|')[2] +"-"+ item.areaName.split('|')[3]
          
        })
        // console.log(this.list);
     },
    async shopCollection(){
       let obj = {
          userID :  window.localStorage.user_id
        }
      let {
          data,
          meta: { msg, status }
        } = await getShopCollection(obj.userID);
      // console.log(data);
      this.shopList = data
    }
  }
};
</script>
        
<style  lang="less" scoped>
 .principal {
 background: #ededed;
//  height: 1334px;
  font-size: 40px;
   header {
    width: 100%;
    height: 88px;
    background-color: #ff5654;
    display: flex;
    .return {
      margin-left: 20px;
      i {
        color: #fff;
        font-size: 34px;
        line-height: 88px;
      }
    }
    .title {
      padding: 0 284px;
      color: #fff;
      font-size: 36px;
      line-height: 88px;
    }
  }
main{
     .tabtext {
    height: 60px;
    font-size: 40px;
  }
  .van-tab__pane{
   padding-top:15px ;

  }
  .tabs {
    height: 60px;
    main {
        
      .contents {
        background-color: #fff;
        display: flex;

        padding: 20px 15px 15px 20px;
        margin: 20px 20px;

        img {
          width: 290px;
          height: 3.2rem;
        }
        .contents1 {
          text-align: left;
          li:nth-child(1) {
            font-size: 20px;
            margin-top: 20px;
          }
          li:nth-child(2) {
            font-size: 18px;
            margin-top: 10px;
          }
          li:nth-child(3) {
            font-size: 17px;
            margin-top: 8px;
             opacity: 0.8;
          }

          margin-left: 20px;
          .contents1_1 {
            margin-top: 36px;
            display: flex;
            font-size: 13px;
            div {
              font-size: 10px;
              color: #618698;
              text-align: center;
              width: 70px;
              height: 30px;
              border: 1px solid #618698;
               line-height: 30px;
              border-radius: 5px;
            }
            span {
              color: #ff5555;
              margin-left: 100px;
                font-size: 25px;
            }
          }
        }
      }
      .van-cell-group--inset {
        margin-top: 30px;
        border-radius: 0;
      }
    }
  }
}
}
</style>